#include "Block.h"

Vector<Block *> *Block::blocks = new Vector<Block * >();

Block * Block::createWithArgs(Color3B color, Size size, std::string label, float fontSize, Color4B textColor)
{
	auto block = new Block();
	block->initWithArgs(color,size,label,fontSize,textColor);
	block->autorelease();
	blocks->pushBack(block);

	return block;
}


bool Block::initWithArgs(Color3B color, Size size, std::string label, float fontSize, Color4B textColor)
{
	if (!Sprite::init())
	{
		return false;
	}

	lineIndex = 0;
	setContentSize(size);
	setAnchorPoint(Point::ZERO);
	setTextureRect(Rect(0,0,size.width,size.height));
	setColor(color);

	auto l = Label::create();
	l->setString(label);
	l->setSystemFontSize(fontSize);
	l->setTextColor(textColor);
	addChild(l);
	l->setPosition(size.width/2,size.height/2);

	return true;
}


void Block::removeBlock()
{

}


int Block::getLineIndex()
{
	return this->lineIndex;
}
void Block::setLineIndex(int lineIndex)
{
	this->lineIndex = lineIndex;
}